<template>
  <div class="banner">
    <el-carousel :interval="2000" :width="1535" arrow="always"  :height="banH +'px'" >//:height设置自适应高度
      <el-carousel-item v-for="(item,index) in list_img" :key="index">
        <h3>
          <img :src="item.url" alt=""/>
        </h3>
      </el-carousel-item>
    </el-carousel>
  </div>
</template>

<script>
export default {
  name: "banner",
  data(){
    return{
      banH:650,
      list_img:[
        { url: require('../../assets/images/banner1.jpg') },
        { url: require('../../assets/images/banner2.jpg') },
        { url: require('../../assets/images/banner3.jpg') },
        { url: require('../../assets/images/banner5.jpg') },
        { url: require('../../assets/images/mainpicture.png') },

      ]
    }
  },methods:{
    setbanH(){
      this.banH=500
    }
  },
  mounted() {

    this.setbanH()

    window.addEventListener('resize', () => {

      this.setbanH()

    }, false)
  },
}
</script>

<style scoped>
.banner {
  margin: 0 auto;
  width: 100%;
  height:70%;
}
.el-carousel__item h3 {
  color: #475669;
  font-size: 18px;
  opacity: 0.75;
  line-height: 300px;
  margin: 0;
}
.el-carousel__item h3 >img{
  width: 100%;
  height: 70%;
}
.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n+1) {
  background-color: #d3dce6;
}

</style>